package com.boot.persistence.validate.annotation;

import com.boot.persistence.validate.validator.UpdateValidator;

import javax.validation.Constraint;
import javax.validation.Payload;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

/**
 * @author 霜寒 <1621856595@qq.com>
 * @description 更新操作的验证注解（仅作用于数据库实体类）
 * @date 2020/4/8 15:27
 **/

@Target({TYPE_USE})
@Retention(RUNTIME)
@Documented
@Constraint(validatedBy = UpdateValidator.class)
public @interface Update {

    String message() default "需要 id 和 除基本属性之外的任意属性";

    Class<?>[] groups() default {};

    Class<? extends Payload>[] payload() default {};

    @Target({METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER, TYPE_USE})
    @Retention(RUNTIME)
    @Documented
    @interface List {
        Update[] value();
    }

}
